/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.base.db.impl;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.base.model.Function;
import com.yunhoo.base.db.dao.FunctionDao;
import com.yunhoo.sys.db.util.DbTool;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Administrator
 */
public class FunctionDaoImpl extends SqlMapDaoTemplate implements FunctionDao {

    private static SqlMapClient sqlmap;
    private String nameSpace = "function.";

    public FunctionDaoImpl(DaoManager daoManager) {
        super(daoManager);
        sqlmap = DbTool.getSqlMapClient();
    }

    @Override
    public void insert(Function param) throws SQLException {
        System.out.println(nameSpace + "insert");
        sqlmap.insert(nameSpace + "insert", param);
    }

    @Override
    public void update(Function param) throws SQLException {
        System.out.println(nameSpace + "update");
        sqlmap.update(nameSpace + "update", param);
    }

    @Override
    public void delete(Function param) throws SQLException {
        System.out.println(nameSpace + "delete");
        sqlmap.delete(nameSpace + "delete", param);
    }

    @Override
    public void deleteById(Function param) throws SQLException {
        System.out.println(nameSpace + "deleteById");
        sqlmap.delete(nameSpace + "deleteById", param);
    }

    @Override
    public Function queryById(Function param) throws SQLException {
        System.out.println(nameSpace + "queryById");
        return (Function) sqlmap.queryForObject(nameSpace + "queryById", param);
    }

    @Override
    public List<Function> queryAll(Function param) throws SQLException {
        return sqlmap.queryForList(nameSpace + "queryAll", param);
    }

    @Override
    public void updateIsEnd(Function param) throws SQLException {
        System.out.println(nameSpace + "updateIsEnd");
        sqlmap.update(nameSpace + "updateIsEnd", param);
    }

    @Override
    public Function nameRepeatForInsert(Function param) throws SQLException {
        System.out.println(nameSpace + "nameRepeatForInsert");
        return (Function) sqlmap.queryForObject(nameSpace + "nameRepeatForInsert", param);
    }

    @Override
    public Function nameRepeatForUpdate(Function param) throws SQLException {
        System.out.println(nameSpace + "nameRepeatForUpdate");
        return (Function) sqlmap.queryForObject(nameSpace + "nameRepeatForUpdate", param);
    }

    @Override
    public List<Function> directSubNodes(Function param) throws SQLException {
        System.out.println(nameSpace + "directSubNodes");
        return sqlmap.queryForList(nameSpace + "directSubNodes", param);
    }

    @Override
    public List<Function> queryListByOrgAndYear(Function param) throws SQLException {
        System.out.println(nameSpace + "queryListByOrgAndYear");
        return sqlmap.queryForList(nameSpace + "queryListByOrgAndYear", param);

    }
}
